﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Webcam_Filter
{
    public abstract class Filter
    {
        public void filter(System.Drawing.Bitmap img, string[] args)
        {
            System.Drawing.Color c = img.GetPixel(0, 0);
            // Lock the bitmap's bits.  
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, img.Width, img.Height);
            System.Drawing.Imaging.BitmapData bmpData =
                img.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
                img.PixelFormat);

            // Get the address of the first line.
            IntPtr ptr = bmpData.Scan0;

            // Declare an array to hold the bytes of the bitmap.
            int bytes = Math.Abs(bmpData.Stride) * img.Height;
            byte[] rgbValues = new byte[bytes];

            // Copy the RGB values into the array.
            System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);

            runfilter(rgbValues, img.Height,img.Width, args);
            // Copy the RGB values back to the bitmap
            System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);

            // Unlock the bits.
            img.UnlockBits(bmpData);
        }
        protected abstract void runfilter(byte[] rgbValues, int hoogte, int breedte, string[] args);

    }
}
